package com.fafu.rbac.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fafu.rbac.domain.entity.Permission;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {

    @Select("""
        SELECT tb_permission.`code`
        FROM tb_permission
        INNER JOIN tb_role_permission
        ON 	tb_permission.id = tb_role_permission.permission_id
        WHERE tb_role_permission.role_id = ${roleId}
    """)
    List<Permission> selectPermissionByRoleId(@Param("roleId") Long roleId);
}